package com.wl2o2o.leetcode;
import java.util.ArrayList;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long cnt = 0;
        long cnt0 = 0;
        ArrayList<Integer> list = new ArrayList<>();
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int q = in.nextInt();
            for (int i = 0; i < n; i++) {
                list.add(in.nextInt());
                cnt += list.get(i);
                if (list.get(i) == 0) cnt0++;
                // System.out.print(list.get(i));
            }
            for (int i = 0; i < q; i++) {
                long l = in.nextLong();
                long r = in.nextLong();
                System.out.println((cnt + l*cnt0) + " " + (cnt + r*cnt0));
            }
        }
    }
}